{#**
*
* 功能描述（列表模板）
*
* @author suoya <jlusuoya@gmail.com>
* @version 1
*#}
{#include file="header.tpl" title="title" active="manager" #}
<div class="content middle">
    <div class="ui breadcrumb">
        <a class="section" href="index.php">主页</a>
        <i class="right"></i>
        <a class="active section">管理员管理</a>
    </div>
    <table class="ui table segment">
        <thead>
            <tr>
                <th>ID</th>
                <th>手机</th>
                <th>账号</th>
                <th>邮件</th>
                <th>姓名</th>
                <th>注册时间</th>
                <th>最后登录</th>
                <th>描述</th>
                <th>重置密码</th>
            </tr>
        </thead>
        <tbody>
            {#foreach $listdata as $item#}
                <tr>
                    <td><a href="index.php?action=admin.info&id={#$item['id']#}">ID {#$item['id']#}</a></td>
                    <td>{#$item['mobile']#}</td>
                    <td>{#$item['name']#}</td>
                    <td>{#$item['email']#}</td>
                    <td>{#$item['truename']#}</td>
                    <td>{#$item['regtime']#}</td>
                    <td>{#$item['lastlogin']#}</td>
                    <td>{#$item['desp']#}</td>
                    <td>
                        <a href="index.php?action=admin.setpwd&id={#$item['id']#}&pwd=" onclick="ajax_this(this);
                                return false">重置密码</a>
                    </td>
                </tr>
                <tr>
            <form action="index.php?action=admin.setperm&id={#$item['id']#}" method="POST" onsubmit="ajax_commit(this);
                    return false">
                <td colspan="8">
                    <input type="checkbox" class="checkAll"{#if $item['p_cake'] == 1 and $item['p_order'] == 1 and $item['p_prod'] == 1 and $item['p_dely'] == 1 and $item['p_msg'] == 1 and $item['p_user'] == 1 and $item['p_log'] == 1 and $item['p_adm'] == 1#} checked="checked"{#/if#} />全选 |
                    <input type="checkbox" class="checkSub" name="cake" value=1{#if $item['p_cake'] == 1#} checked="checked"{#/if#} />蛋糕管理 |
                    <input type="checkbox" class="checkSub" name="order" value=1{#if $item['p_order'] == 1#} checked="checked"{#/if#} />订单管理 |
                    <input type="checkbox" class="checkSub" name="prod" value=1{#if $item['p_prod'] == 1#} checked="checked"{#/if#} />生产管理 |
                    <input type="checkbox" class="checkSub" name="dely" value=1{#if $item['p_dely'] == 1#} checked="checked"{#/if#} />配送管理 |
                    <input type="checkbox" class="checkSub" name="msg" value=1{#if $item['p_msg'] == 1#} checked="checked"{#/if#} />留言管理 |
                    <input type="checkbox" class="checkSub" name="user" value=1{#if $item['p_user'] == 1#} checked="checked"{#/if#} />会员管理 |
                    <input type="checkbox" class="checkSub" name="log" value=1{#if $item['p_log'] == 1#} checked="checked"{#/if#} />系统日志 |
                    <input type="checkbox" class="checkSub" name="adm" value=1{#if $item['p_adm'] == 1#} checked="checked"{#/if#} />管理员管理 |
                </td>
                <td>
                    <input type="submit" value="更新权限" />
                </td>
            </form>
            </tr>
        {#/foreach#}
        </tbody>
        <tfoot>
            <tr>
                <th colspan="9" style="font-style: normal;">
                    {#include file="paging_bar.tpl"#}
                </th>
            </tr>
        </tfoot>
    </table>
    <div class="search" style="margin-top: 10px;">
        <div class="searchTitle">
            添加管理员
        </div>
        <div class="searchBar" style=" line-height: normal; padding: 5px;">
            <form class="ui form" id="addForm" action="index.php?action=admin.add" method="POST" onsubmit="validForm()">
                <div class="inputDIV centerDIV">
                    <label class="title3">账号：<span class="prompt">*</span></label>
                    <input type='text' name='username' class="input_text" id='username'/>
                    <label class="tip">账号为管理员登陆账号，请输入字母、数字、下划线组合</label>
                </div>
                <div class="inputDIV centerDIV">
                    <label class="title3">密码：<span class="prompt">*</span></label>
                    <input type='password' name='password' class="input_text" />
                    <label class="title3">手机号：<span class="prompt">*</span></label>
                    <input type='text' name='mobile' class="input_text"/>
                    <label class="title3">姓名：<span class="prompt">*</span></label>
                    <input type='text' name='truename' class="input_text"/>
                </div>
                <div class="inputDIV centerDIV">
                    <label class="title3">邮箱：<span class="prompt">*</span></label>
                    <input type='text' name='email' class="input_text"/>
                    <label class="title3">描述：<span class="prompt">*</span></label>
                    <input type='text' name='desp' class="input_text" style="width: 394px;"/>
                </div>
                <div class="inputDIV centerDIV">
                    <input type="text" style="display: none" />
                    <input type="checkbox" class="checkAll" />全选 |
                    <input type="checkbox" class="checkSub" name="cake" value=1 />蛋糕管理 |
                    <input type="checkbox" class="checkSub" name="order" value=1 />订单管理 |
                    <input type="checkbox" class="checkSub" name="prod" value=1 />生产管理 |
                    <input type="checkbox" class="checkSub" name="dely" value=1 />配送管理 |
                    <input type="checkbox" class="checkSub" name="msg" value=1 />留言管理 |
                    <input type="checkbox" class="checkSub" name="user" value=1 />会员管理 |
                    <input type="checkbox" class="checkSub" name="log" value=1 />系统日志 |
                    <input type="checkbox" class="checkSub" name="adm" value=1 />管理员管理
                </div>
                <div class="ui error message">
                    <div class="header">We noticed some issues</div>
                </div>
                <div class="inputDIV">
                    <input class="button align_right" type="submit" value="添加管理员" />
                </div>
            </form>
            <script>
                $(function() {
                    $(".checkAll").click(function() {
                        var flag = this.checked;
                        $(this).parent().children('.checkSub:checkbox').each(function() {
                            this.checked = flag;
                        });
                    });
                });

                $('.ui.checkbox').checkbox();
                $('#addForm').form({
                    username: {
                        identifier: 'username',
                        rules: [
                            {
                                type: 'empty',
                                prompt: '请输入账号'
                            }
                        ]
                    },
                    password: {
                        identifier: 'password',
                        rules: [
                            {
                                type: 'empty',
                                prompt: '请输入密码'
                            }
                        ]
                    },
                    mobile: {
                        identifier: 'mobile',
                        rules: [
                            {
                                type: 'empty',
                                prompt: '请输入手机'
                            }
                        ]
                    },
                    email: {
                        identifier: 'email',
                        rules: [
                            {
                                type: 'empty',
                                prompt: '请输入邮箱'
                            },
                            {
                                type: 'email',
                                prompt: '请输入正确的邮箱'
                            }
                        ]
                    },
                    truename: {
                        identifier: 'truename',
                        rules: [
                            {
                                type: 'empty',
                                prompt: '请输入姓名'
                            }
                        ]
                    },
                    desp: {
                        identifier: 'desp',
                        rules: [
                            {
                                type: 'empty',
                                prompt: '请输入描述'
                            }
                        ]
                    }
                });
                
                function validForm() {
                    var username = $("#username");
                    if (!/^\w+$/.test(username.val())) {
                        alert("账号为管理员登陆账号，请输入字母、数字、下划线组合");
                        username.focus();
                        return false;
                    }
                    return true;
                }
            </script>
        </div>
    </div>
</div>
{#include file="footer.tpl" #}
